#include <2025Linux.h>
int main(int argc, char *argv[])
{
    // ./09_redirect3 file1
    ARGS_CHECK(argc,2);
    int oldfd = open(argv[1],O_RDWR);
    ERROR_CHECK(oldfd,-1,"open");

    printf("1 我过来啦\n");
    int backfd = 10;//backfd用来备份屏幕
    dup2(STDOUT_FILENO,backfd);
    dup2(oldfd,STDOUT_FILENO);//让1关联磁盘文件
    printf("2 我过去啦\n");
    dup2(backfd,STDOUT_FILENO);
    printf("3 我又过来啦\n");

    close(oldfd);
    return 0;
}

